package com.ivncorp.evnproject.helpers;

import java.util.ArrayList;

import android.location.Location;

import com.google.android.gms.maps.GoogleMap;
import com.ivncorp.evnproject.model.ObjectCot;
import com.ivncorp.evnproject.model.ObjectTram;
import com.ivncorp.evnproject.model.ObjectTuTT;

public class Variables {
	private static GoogleMap currentGoogleMap = null;
	public static ArrayList<ObjectTram> currentListObjectTable = new ArrayList<ObjectTram>();
	public static ArrayList<ObjectCot> currentListObjectCot = new ArrayList<ObjectCot>();
	public static ArrayList<ObjectTuTT> currentListObjectTuTT = new ArrayList<ObjectTuTT>();
	public static String userName;
	private Location location;
	double latitude = 0.0;
	double longitude = 0.0;
	public static final String NAME_DATABSE = "evnepu-db";
	
	public Variables(GoogleMap map)
	{
		currentGoogleMap=map;
	}
	
	public Variables(){
		
		location = currentGoogleMap.getMyLocation();
		if (location != null){
			latitude = location.getLatitude();
			longitude = location.getLongitude();
		}
	}
	
	public String getLatitude() {

		String result = null;

		if (location != null) {
			latitude = location.getLatitude();
			// convert
			int num1Lat = (int) Math.floor(latitude);
			int num2Lat = (int) Math.floor((latitude - num1Lat) * 60);
			double num3Lat = (latitude - ((double) num1Lat + ((double) num2Lat / 60))) * 3600000;
			result = num1Lat + "/1," + num2Lat + "/1," + num3Lat + "/1000";
		}

		return result;
	}

	public String getLatitudeRef() {
		return latitude < 0.0d ? "S" : "N";
	}

	public String getLongitude() {
		String result = null;
		if (location != null) {
			longitude = location.getLongitude();
			// convert
			int num1Lat = (int) Math.floor(longitude);
			int num2Lat = (int) Math.floor((longitude - num1Lat) * 60);
			double num3Lat = (longitude - ((double) num1Lat + ((double) num2Lat / 60))) * 3600000;
			result = num1Lat + "/1," + num2Lat + "/1," + num3Lat + "/1000";
		}
		return result;
	}

	public String getLongitudeRef() {
		return longitude < 0.0d ? "W" : "E";
	}
	
}
